package com.yuntsg.nnsfcp.util.zhang;

import org.apache.http.HttpHost;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;

public class LoadInfo {
//    private static String PROXY_STR = null;
//    private static Integer PORT_STR = null;
//    private static String USER_NAME_STR = null;
//    private static String PASSWORD_STR = null;

//    static {
//        ResourceBundle proxy = ResourceBundle.getBundle("proxy");
//        PROXY_STR = proxy.getString("proxyStr");
//        PORT_STR = Integer.valueOf(proxy.getString("portStr"));
//        USER_NAME_STR = proxy.getString("userNameStr");
//        PASSWORD_STR = proxy.getString("passwordStr");
//    }

//    public static CredentialsProvider build() {
//        CredentialsProvider credsProvider = new BasicCredentialsProvider();
//        credsProvider.setCredentials(new AuthScope(PROXY_STR, PORT_STR), (Credentials) new UsernamePasswordCredentials(USER_NAME_STR, PASSWORD_STR));
//        return credsProvider;
//    }

//    public static CredentialsProvider build1() {
//        CredentialsProvider credsProvider = new BasicCredentialsProvider();
//        credsProvider.setCredentials(new AuthScope("127.0.0.1", 8888), (Credentials) new UsernamePasswordCredentials(USER_NAME_STR, PASSWORD_STR));
//        return credsProvider;
//    }

    public static RequestConfig buildRequestConfigureWithProxy(boolean JumpFlag) {
        RequestConfig requestConfig = RequestConfig.custom()
                //没有链接,没有响应超时断开
                .setSocketTimeout(60000)
                //链接后没有响应数据, 超时断开
                .setConnectTimeout(60000)
                //设置使用标准cookie
                .setCookieSpec(CookieSpecs.STANDARD)
//                                                   .setProxy(new HttpHost(PROXY_STR, PORT_STR))
//				.setRedirectsEnabled(JumpFlag)
                .build();// 设置请求和传输超时时间
        return requestConfig;
    }

    public static RequestConfig buildRequestConfigureWithProxy1(boolean JumpFlag) {
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(30000)
                .setConnectTimeout(30000)
                .setProxy(new HttpHost("127.0.0.1", 8888))
                .setRedirectsEnabled(JumpFlag)
                .build();// 设置请求和传输超时时间
        return requestConfig;
    }

    public static RequestConfig buildRequestConfigureWithOutProxy(boolean JumpFlag) {
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(60000)
                .setConnectTimeout(60000)
                //.setProxy(new HttpHost("202.120.23.59",10086))
//				.setRedirectsEnabled(JumpFlag)
                .build();// 设置请求和传输超时时间
        return requestConfig;
    }


}
